{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from requests_html import HTMLSession"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 学校要闻"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "session = HTMLSession()\n",
    "r = session.get(\"https://www.nfu.edu.cn/xxyw/index.htm\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "title = r.html.xpath('//div[@class=\"news_title\"]/a/@title')\n",
    "links = r.html.xpath('//div[@class=\"news_title\"]/a/@href')\n",
    "data = r.html.xpath('//font[@class=\"right-more\"]/text()')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "# new_link = []\n",
    "# for i in links:\n",
    "#     j = \"https://www.nfu.edu.cn/xxyw/\"+i\n",
    "#     new_link.append(j)\n",
    "# new_link"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(90):\n",
    "    r = session.get(\"https://www.nfu.edu.cn/xxyw/index%d.htm\"%(i))\n",
    "    title.extend(r.html.xpath('//div[@class=\"news_title\"]/a/@title')) \n",
    "    links.extend(r.html.xpath('//div[@class=\"news_title\"]/a/@href'))\n",
    "    data.extend(r.html.xpath('//font[@class=\"right-more\"]/text()'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>链结</th>\n",
       "      <th>日期</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>我校召开2021年一流专业、一流课程、教学成果奖申报工作推进会</td>\n",
       "      <td>https://www.nfu.edu.cn/xxyw/48b0929919ec4d2d9a...</td>\n",
       "      <td>2021-04-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>我校承办首届 “新时代从商培养工程”</td>\n",
       "      <td>https://www.nfu.edu.cn/xxyw/0d7bd841484a42a69d...</td>\n",
       "      <td>2021-04-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>专注当下，冲刺高考，奋斗出最美的青春</td>\n",
       "      <td>https://www.nfu.edu.cn/xxyw/f9bcd8092b494a04be...</td>\n",
       "      <td>2021-04-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>广东工业大学华立学院来访我校</td>\n",
       "      <td>https://www.nfu.edu.cn/xxyw/debb2f222e024cbda5...</td>\n",
       "      <td>2021-03-31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>“疫情下的中国、美国以及中美关系”高层论坛暨广州南方学院“美国研究中心”成立五周年纪念研讨会</td>\n",
       "      <td>https://www.nfu.edu.cn/xxyw/e5378134dbaf4b7b88...</td>\n",
       "      <td>2021-03-31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1795</th>\n",
       "      <td>我院多个项目获2013年度省级以上本科教学质量工程项目立项</td>\n",
       "      <td>https://www.nfu.edu.cn/xxyw/e2ef39bdace94f3da9...</td>\n",
       "      <td>2013-10-11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1796</th>\n",
       "      <td>首届从化地区学工部（处）联谊会在我院举行</td>\n",
       "      <td>https://www.nfu.edu.cn/xxyw/5a530157f3764b32ad...</td>\n",
       "      <td>2013-09-29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1797</th>\n",
       "      <td>我院经管系2013级创新实验国际班开班典礼隆重举行</td>\n",
       "      <td>https://www.nfu.edu.cn/xxyw/2af0127ce4234c7aa5...</td>\n",
       "      <td>2013-09-29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1798</th>\n",
       "      <td>学院教学工作会议顺利召开</td>\n",
       "      <td>https://www.nfu.edu.cn/xxyw/b844901be7a6412eb7...</td>\n",
       "      <td>2013-09-26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1799</th>\n",
       "      <td>我院召开新进教职工座谈会</td>\n",
       "      <td>https://www.nfu.edu.cn/xxyw/460879ee62c94531ba...</td>\n",
       "      <td>2013-09-25</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1800 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                  标题  \\\n",
       "0                    我校召开2021年一流专业、一流课程、教学成果奖申报工作推进会   \n",
       "1                                 我校承办首届 “新时代从商培养工程”   \n",
       "2                                 专注当下，冲刺高考，奋斗出最美的青春   \n",
       "3                                     广东工业大学华立学院来访我校   \n",
       "4     “疫情下的中国、美国以及中美关系”高层论坛暨广州南方学院“美国研究中心”成立五周年纪念研讨会   \n",
       "...                                              ...   \n",
       "1795                   我院多个项目获2013年度省级以上本科教学质量工程项目立项   \n",
       "1796                            首届从化地区学工部（处）联谊会在我院举行   \n",
       "1797                       我院经管系2013级创新实验国际班开班典礼隆重举行   \n",
       "1798                                    学院教学工作会议顺利召开   \n",
       "1799                                    我院召开新进教职工座谈会   \n",
       "\n",
       "                                                     链结          日期  \n",
       "0     https://www.nfu.edu.cn/xxyw/48b0929919ec4d2d9a...  2021-04-02  \n",
       "1     https://www.nfu.edu.cn/xxyw/0d7bd841484a42a69d...  2021-04-02  \n",
       "2     https://www.nfu.edu.cn/xxyw/f9bcd8092b494a04be...  2021-04-02  \n",
       "3     https://www.nfu.edu.cn/xxyw/debb2f222e024cbda5...  2021-03-31  \n",
       "4     https://www.nfu.edu.cn/xxyw/e5378134dbaf4b7b88...  2021-03-31  \n",
       "...                                                 ...         ...  \n",
       "1795  https://www.nfu.edu.cn/xxyw/e2ef39bdace94f3da9...  2013-10-11  \n",
       "1796  https://www.nfu.edu.cn/xxyw/5a530157f3764b32ad...  2013-09-29  \n",
       "1797  https://www.nfu.edu.cn/xxyw/2af0127ce4234c7aa5...  2013-09-29  \n",
       "1798  https://www.nfu.edu.cn/xxyw/b844901be7a6412eb7...  2013-09-26  \n",
       "1799  https://www.nfu.edu.cn/xxyw/460879ee62c94531ba...  2013-09-25  \n",
       "\n",
       "[1800 rows x 3 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame( {\n",
    "        \"标题\": title,\n",
    "        \"链结\": [\"https://www.nfu.edu.cn/xxyw/\"+i for i in links],\n",
    "        \"日期\": data,\n",
    "             } )\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df.to_excel(\"学校要闻.xlsx\", sheet_name=\"南方学院学校要闻\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 校园动态"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "session = HTMLSession()\n",
    "r1 = session.get(\"https://www.nfu.edu.cn/xydt/index.htm\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "title = r1.html.xpath('//div[@class=\"news_title\"]/a/@title')\n",
    "links = r1.html.xpath('//div[@class=\"news_title\"]/a/@href')\n",
    "data = r1.html.xpath('//font[@class=\"right-more\"]/text()')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(84):\n",
    "    r1 = session.get(\"https://www.nfu.edu.cn/xydt/index%d.htm\"%(i))\n",
    "    title.extend(r1.html.xpath('//div[@class=\"news_title\"]/a/@title')) \n",
    "    links.extend(r1.html.xpath('//div[@class=\"news_title\"]/a/@href'))\n",
    "    data.extend(r1.html.xpath('//font[@class=\"right-more\"]/text()'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>链结</th>\n",
       "      <th>日期</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>商学院电子商务专业召开申请调整学位授予学科门类 专家评审会</td>\n",
       "      <td>https://www.nfu.edu.cn/xydt/cf4420785b9046e998...</td>\n",
       "      <td>2021-04-07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>广州新华学院会计学院刘运国院长一行莅临我院访问</td>\n",
       "      <td>https://www.nfu.edu.cn/xydt/935f580040704990a4...</td>\n",
       "      <td>2021-04-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>会计学院大一年级大会顺利召开</td>\n",
       "      <td>https://www.nfu.edu.cn/xydt/16f4c5f4bd284caebf...</td>\n",
       "      <td>2021-04-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>【国奖映像】蒋晓琳：明确目标，为之努力</td>\n",
       "      <td>https://www.nfu.edu.cn/xydt/9611d110ec8a486587...</td>\n",
       "      <td>2021-04-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>“远离糖尿病，筑起健康防线” 护理与健康学院寒假社会实践调查成果汇报展示圆满结束</td>\n",
       "      <td>https://www.nfu.edu.cn/xydt/2f3dcc0f4400419e8e...</td>\n",
       "      <td>2021-03-29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1675</th>\n",
       "      <td>产教结合，共享双赢——电软系赴企业考察交流</td>\n",
       "      <td>https://www.nfu.edu.cn/xydt/fbe740cdd4534c20af...</td>\n",
       "      <td>2016-01-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1676</th>\n",
       "      <td>电软系召开工程教育专业认证课程改革项目中期检查会</td>\n",
       "      <td>https://www.nfu.edu.cn/xydt/7367ece3043744caac...</td>\n",
       "      <td>2016-01-18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1677</th>\n",
       "      <td>海峡两岸同根源，共为南院谋发展——团委与台湾籍教师第一次交流茶话会成功举办</td>\n",
       "      <td>https://www.nfu.edu.cn/xydt/ff3a705f1c104117a4...</td>\n",
       "      <td>2016-01-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1678</th>\n",
       "      <td>文学与传媒系2016年学术研讨会议成功举办</td>\n",
       "      <td>https://www.nfu.edu.cn/xydt/ae2cf68f6b1247a6a1...</td>\n",
       "      <td>2016-01-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1679</th>\n",
       "      <td>广东技术师范学院大学英语部与我院大学英语教学中心教师交流会顺利举行</td>\n",
       "      <td>https://www.nfu.edu.cn/xydt/5cc461d4a37a4afb8d...</td>\n",
       "      <td>2016-01-08</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1680 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                            标题  \\\n",
       "0                商学院电子商务专业召开申请调整学位授予学科门类 专家评审会   \n",
       "1                      广州新华学院会计学院刘运国院长一行莅临我院访问   \n",
       "2                               会计学院大一年级大会顺利召开   \n",
       "3                          【国奖映像】蒋晓琳：明确目标，为之努力   \n",
       "4     “远离糖尿病，筑起健康防线” 护理与健康学院寒假社会实践调查成果汇报展示圆满结束   \n",
       "...                                        ...   \n",
       "1675                     产教结合，共享双赢——电软系赴企业考察交流   \n",
       "1676                  电软系召开工程教育专业认证课程改革项目中期检查会   \n",
       "1677     海峡两岸同根源，共为南院谋发展——团委与台湾籍教师第一次交流茶话会成功举办   \n",
       "1678                     文学与传媒系2016年学术研讨会议成功举办   \n",
       "1679         广东技术师范学院大学英语部与我院大学英语教学中心教师交流会顺利举行   \n",
       "\n",
       "                                                     链结          日期  \n",
       "0     https://www.nfu.edu.cn/xydt/cf4420785b9046e998...  2021-04-07  \n",
       "1     https://www.nfu.edu.cn/xydt/935f580040704990a4...  2021-04-06  \n",
       "2     https://www.nfu.edu.cn/xydt/16f4c5f4bd284caebf...  2021-04-06  \n",
       "3     https://www.nfu.edu.cn/xydt/9611d110ec8a486587...  2021-04-02  \n",
       "4     https://www.nfu.edu.cn/xydt/2f3dcc0f4400419e8e...  2021-03-29  \n",
       "...                                                 ...         ...  \n",
       "1675  https://www.nfu.edu.cn/xydt/fbe740cdd4534c20af...  2016-01-25  \n",
       "1676  https://www.nfu.edu.cn/xydt/7367ece3043744caac...  2016-01-18  \n",
       "1677  https://www.nfu.edu.cn/xydt/ff3a705f1c104117a4...  2016-01-13  \n",
       "1678  https://www.nfu.edu.cn/xydt/ae2cf68f6b1247a6a1...  2016-01-08  \n",
       "1679  https://www.nfu.edu.cn/xydt/5cc461d4a37a4afb8d...  2016-01-08  \n",
       "\n",
       "[1680 rows x 3 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 = pd.DataFrame( {\n",
    "        \"标题\": title,\n",
    "        \"链结\": [\"https://www.nfu.edu.cn/xydt/\"+i for i in links],\n",
    "        \"日期\": data,\n",
    "             } )\n",
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df1.to_excel(\"作业.xlsx\", sheet_name=\"南方学院校园动态\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "# # 创建一个空的excel文件\n",
    "# # nan_excle = pd.DataFrame()\n",
    "# # nan_excel.to_excel(\"homework.xlsx\")\n",
    "# sheets =[\"校园动态\"]\n",
    "# #\n",
    "# # 打开excel\n",
    "# writer = pd.ExcelWriter(\"homework.xlsx\")\n",
    "# #sheets是要写入的excel工作簿名称列表\n",
    "# for sheet in sheets:\n",
    "#     df1.to_excel(writer, sheet_name=sheet)\n",
    "\n",
    "# # 保存writer中的数据至excel\n",
    "# # 如果省略该语句，则数据不会写入到上边创建的excel文件中\n",
    "# writer.save()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 通知公告"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>链结</th>\n",
       "      <th>日期</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>校园管理部关于2021年元旦放假校园生活服务安排的通知</td>\n",
       "      <td>https://www.nfu.edu.cn/tzgg/cd60e06378e5449294...</td>\n",
       "      <td>2020-12-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>中山大学南方学院关于2021年元旦放假安排的通知</td>\n",
       "      <td>https://www.nfu.edu.cn/tzgg/16fcbd56eab04220b3...</td>\n",
       "      <td>2020-12-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>关于开展2020年知识产权竞赛的通知</td>\n",
       "      <td>https://www.nfu.edu.cn/tzgg/155655d4a7e74c7695...</td>\n",
       "      <td>2020-12-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>中山大学南方学院关于举办2020年预防艾滋病巡讲活动的通知</td>\n",
       "      <td>https://www.nfu.edu.cn/tzgg/f381db0e5b3e4746b3...</td>\n",
       "      <td>2020-12-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>关于开展2020年安全知识竞赛的通知</td>\n",
       "      <td>https://www.nfu.edu.cn/tzgg/ae83ecc6ce894bcb81...</td>\n",
       "      <td>2020-12-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>682</th>\n",
       "      <td>“南苑青年”系列讲座之第十三讲的通知</td>\n",
       "      <td>https://www.nfu.edu.cn/tzgg/bbd14d55a99247a79f...</td>\n",
       "      <td>2015-04-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>683</th>\n",
       "      <td>中山大学南方学院关于举办“南方湖畔·艺彩纷呈”第七届校园文化艺术节活动通知</td>\n",
       "      <td>https://www.nfu.edu.cn/tzgg/a8e5e752e409486da2...</td>\n",
       "      <td>2015-04-07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>684</th>\n",
       "      <td>学院办公室关于2015年五一放假安排的通知</td>\n",
       "      <td>https://www.nfu.edu.cn/tzgg/e3f763049ee54cfc8c...</td>\n",
       "      <td>2015-04-01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>685</th>\n",
       "      <td>中山大学南方学院关于2015年公共机构节能宣传作品征集活动的通知</td>\n",
       "      <td>https://www.nfu.edu.cn/tzgg/f3ae1aa3ccdb4d87bc...</td>\n",
       "      <td>2015-04-01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>686</th>\n",
       "      <td>关于开展校园网络和运营商移动网络使用情况调查的通知</td>\n",
       "      <td>https://www.nfu.edu.cn/tzgg/6de44f6a618540ef82...</td>\n",
       "      <td>1970-01-01</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>687 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                        标题  \\\n",
       "0              校园管理部关于2021年元旦放假校园生活服务安排的通知   \n",
       "1                 中山大学南方学院关于2021年元旦放假安排的通知   \n",
       "2                       关于开展2020年知识产权竞赛的通知   \n",
       "3            中山大学南方学院关于举办2020年预防艾滋病巡讲活动的通知   \n",
       "4                       关于开展2020年安全知识竞赛的通知   \n",
       "..                                     ...   \n",
       "682                     “南苑青年”系列讲座之第十三讲的通知   \n",
       "683  中山大学南方学院关于举办“南方湖畔·艺彩纷呈”第七届校园文化艺术节活动通知   \n",
       "684                  学院办公室关于2015年五一放假安排的通知   \n",
       "685       中山大学南方学院关于2015年公共机构节能宣传作品征集活动的通知   \n",
       "686              关于开展校园网络和运营商移动网络使用情况调查的通知   \n",
       "\n",
       "                                                    链结          日期  \n",
       "0    https://www.nfu.edu.cn/tzgg/cd60e06378e5449294...  2020-12-25  \n",
       "1    https://www.nfu.edu.cn/tzgg/16fcbd56eab04220b3...  2020-12-17  \n",
       "2    https://www.nfu.edu.cn/tzgg/155655d4a7e74c7695...  2020-12-16  \n",
       "3    https://www.nfu.edu.cn/tzgg/f381db0e5b3e4746b3...  2020-12-03  \n",
       "4    https://www.nfu.edu.cn/tzgg/ae83ecc6ce894bcb81...  2020-12-03  \n",
       "..                                                 ...         ...  \n",
       "682  https://www.nfu.edu.cn/tzgg/bbd14d55a99247a79f...  2015-04-08  \n",
       "683  https://www.nfu.edu.cn/tzgg/a8e5e752e409486da2...  2015-04-07  \n",
       "684  https://www.nfu.edu.cn/tzgg/e3f763049ee54cfc8c...  2015-04-01  \n",
       "685  https://www.nfu.edu.cn/tzgg/f3ae1aa3ccdb4d87bc...  2015-04-01  \n",
       "686  https://www.nfu.edu.cn/tzgg/6de44f6a618540ef82...  1970-01-01  \n",
       "\n",
       "[687 rows x 3 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "session = HTMLSession()\n",
    "r2 = session.get(\"https://www.nfu.edu.cn/tzgg/index.htm\")\n",
    "\n",
    "title = r2.html.xpath('//div[@class=\"news_title\"]/a/@title')\n",
    "links = r2.html.xpath('//div[@class=\"news_title\"]/a/@href')\n",
    "data = r2.html.xpath('//font[@class=\"right-more\"]/text()')\n",
    "\n",
    "for i in range(84):\n",
    "    r2 = session.get(\"https://www.nfu.edu.cn/tzgg/index%d.htm\"%(i))\n",
    "    title.extend(r2.html.xpath('//div[@class=\"news_title\"]/a/@title')) \n",
    "    links.extend(r2.html.xpath('//div[@class=\"news_title\"]/a/@href'))\n",
    "    data.extend(r2.html.xpath('//font[@class=\"right-more\"]/text()'))\n",
    "    \n",
    "df2 = pd.DataFrame( {\n",
    "        \"标题\": title,\n",
    "        \"链结\": [\"https://www.nfu.edu.cn/tzgg/\"+i for i in links],\n",
    "        \"日期\": data,\n",
    "             } )\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df2.to_excel(\"通知公告.xlsx\", sheet_name=\"南方学院通知公告\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 招投标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>链结</th>\n",
       "      <th>日期</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>广州南方学院蚊子、苍蝇、蟑螂消杀及白蚁、红火蚁防治项目 招标公告</td>\n",
       "      <td>https://www.nfu.edu.cn/ztb/ea8754261f26419080a...</td>\n",
       "      <td>2021-04-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>中山大学南方学院数字电路基础实验室、电路与模拟电子实验室设备采购项目招标公告</td>\n",
       "      <td>https://www.nfu.edu.cn/ztb/7226fe9acf3b4757b97...</td>\n",
       "      <td>2021-03-31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中山大学南方学院垃圾清运和处理服务项目招标公告</td>\n",
       "      <td>https://www.nfu.edu.cn/ztb/414b2db5e6c04f99be1...</td>\n",
       "      <td>2021-03-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>中山大学南方学院2021年度维修、改造工程施工项目中标结果公示</td>\n",
       "      <td>https://www.nfu.edu.cn/ztb/60c660848ef44283bca...</td>\n",
       "      <td>2021-03-11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>中山大学南方学院校舍家电采购项目招标公告</td>\n",
       "      <td>https://www.nfu.edu.cn/ztb/c1f45c4ed6d24523b80...</td>\n",
       "      <td>2021-03-05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>428</th>\n",
       "      <td>中山大学南方学院学生体质健康测试仪采购项目招标公告（第二次）</td>\n",
       "      <td>https://www.nfu.edu.cn/ztb/ba01c43761e245d4937...</td>\n",
       "      <td>2015-03-27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>429</th>\n",
       "      <td>中山大学南方学院计算机实验室设备采购项目中标公示</td>\n",
       "      <td>https://www.nfu.edu.cn/ztb/0020f85b9ef24d0792d...</td>\n",
       "      <td>2015-03-26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>430</th>\n",
       "      <td>中山大学南方学院电气工程及自动化实验室设备采购项目招标公告（第二次）</td>\n",
       "      <td>https://www.nfu.edu.cn/ztb/10482a669fc54447aa2...</td>\n",
       "      <td>2015-03-26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>431</th>\n",
       "      <td>中山大学南方学院音乐楼阶梯课室座椅采购项目中标公示</td>\n",
       "      <td>https://www.nfu.edu.cn/ztb/4e5e67a17b7d47cf8cc...</td>\n",
       "      <td>2015-03-20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>432</th>\n",
       "      <td>中山大学南方学院室内高尔夫模拟设备项目招标公告</td>\n",
       "      <td>https://www.nfu.edu.cn/ztb/35a1b4dab36a4ae5aa4...</td>\n",
       "      <td>2013-12-23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>433 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                         标题  \\\n",
       "0          广州南方学院蚊子、苍蝇、蟑螂消杀及白蚁、红火蚁防治项目 招标公告   \n",
       "1    中山大学南方学院数字电路基础实验室、电路与模拟电子实验室设备采购项目招标公告   \n",
       "2                   中山大学南方学院垃圾清运和处理服务项目招标公告   \n",
       "3           中山大学南方学院2021年度维修、改造工程施工项目中标结果公示   \n",
       "4                      中山大学南方学院校舍家电采购项目招标公告   \n",
       "..                                      ...   \n",
       "428          中山大学南方学院学生体质健康测试仪采购项目招标公告（第二次）   \n",
       "429                中山大学南方学院计算机实验室设备采购项目中标公示   \n",
       "430      中山大学南方学院电气工程及自动化实验室设备采购项目招标公告（第二次）   \n",
       "431               中山大学南方学院音乐楼阶梯课室座椅采购项目中标公示   \n",
       "432                 中山大学南方学院室内高尔夫模拟设备项目招标公告   \n",
       "\n",
       "                                                    链结          日期  \n",
       "0    https://www.nfu.edu.cn/ztb/ea8754261f26419080a...  2021-04-02  \n",
       "1    https://www.nfu.edu.cn/ztb/7226fe9acf3b4757b97...  2021-03-31  \n",
       "2    https://www.nfu.edu.cn/ztb/414b2db5e6c04f99be1...  2021-03-17  \n",
       "3    https://www.nfu.edu.cn/ztb/60c660848ef44283bca...  2021-03-11  \n",
       "4    https://www.nfu.edu.cn/ztb/c1f45c4ed6d24523b80...  2021-03-05  \n",
       "..                                                 ...         ...  \n",
       "428  https://www.nfu.edu.cn/ztb/ba01c43761e245d4937...  2015-03-27  \n",
       "429  https://www.nfu.edu.cn/ztb/0020f85b9ef24d0792d...  2015-03-26  \n",
       "430  https://www.nfu.edu.cn/ztb/10482a669fc54447aa2...  2015-03-26  \n",
       "431  https://www.nfu.edu.cn/ztb/4e5e67a17b7d47cf8cc...  2015-03-20  \n",
       "432  https://www.nfu.edu.cn/ztb/35a1b4dab36a4ae5aa4...  2013-12-23  \n",
       "\n",
       "[433 rows x 3 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "session = HTMLSession()\n",
    "r3 = session.get(\"https://www.nfu.edu.cn/ztb/index.htm\")\n",
    "\n",
    "title = r3.html.xpath('//div[@class=\"news_title\"]/a/@title')\n",
    "links = r3.html.xpath('//div[@class=\"news_title\"]/a/@href')\n",
    "data = r3.html.xpath('//font[@class=\"right-more\"]/text()')\n",
    "\n",
    "for i in range(100):\n",
    "    r3 = session.get(\"https://www.nfu.edu.cn/ztb/index%d.htm\"%(i))\n",
    "    title.extend(r3.html.xpath('//div[@class=\"news_title\"]/a/@title')) \n",
    "    links.extend(r3.html.xpath('//div[@class=\"news_title\"]/a/@href'))\n",
    "    data.extend(r3.html.xpath('//font[@class=\"right-more\"]/text()'))\n",
    "    \n",
    "df3 = pd.DataFrame( {\n",
    "        \"标题\": title,\n",
    "        \"链结\": [\"https://www.nfu.edu.cn/ztb/\"+i for i in links],\n",
    "        \"日期\": data,\n",
    "             } )\n",
    "df3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df3.to_excel(\"招投标.xlsx\", sheet_name=\"南方学院招投标\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 高校动态"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>标题</th>\n",
       "      <th>链结</th>\n",
       "      <th>日期</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>如何建设高质量教育体系？“十四五”规划和2035年远景目标纲要明确了</td>\n",
       "      <td>https://www.nfu.edu.cn/gjdt/27ba495edc1b49f88b...</td>\n",
       "      <td>2021-03-15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>教育部长陈宝生《旗帜》撰文：建设高质量教育体系，加快建成教育强国</td>\n",
       "      <td>https://www.nfu.edu.cn/gjdt/20dc120c250642cca5...</td>\n",
       "      <td>2021-01-05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>重磅！《推进粤港澳大湾区高等教育合作发展规划》正式印发</td>\n",
       "      <td>https://www.nfu.edu.cn/gjdt/b43531427fb44695bb...</td>\n",
       "      <td>2020-12-22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>教育部长陈宝生：大力提升青少年宪法法治教育质量</td>\n",
       "      <td>https://www.nfu.edu.cn/gjdt/1509f4f3bc2f4babbe...</td>\n",
       "      <td>2020-12-15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>教育系统如何学习贯彻五中全会精神？教育部最新通知来了</td>\n",
       "      <td>https://www.nfu.edu.cn/gjdt/a4b2fb3dacae456497...</td>\n",
       "      <td>2020-11-20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>506</th>\n",
       "      <td>广东省教育厅：今年毕业生就业形势比去年好</td>\n",
       "      <td>https://www.nfu.edu.cn/gjdt/3829e4c5df9e460abc...</td>\n",
       "      <td>2014-03-28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>507</th>\n",
       "      <td>要求职业“高大上” 高校毕业生择业扎堆致就业难</td>\n",
       "      <td>https://www.nfu.edu.cn/gjdt/776ebc41fae84b36a4...</td>\n",
       "      <td>2014-03-27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>508</th>\n",
       "      <td>教育部：预计今年贫困地区农村学生上重点高校的人数将比去年增加10%以上</td>\n",
       "      <td>https://www.nfu.edu.cn/gjdt/41d339ccb3a0464c9c...</td>\n",
       "      <td>2014-03-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>509</th>\n",
       "      <td>学位论文如何才能挤出“水分”</td>\n",
       "      <td>https://www.nfu.edu.cn/gjdt/1e8fa309bcf847b6ad...</td>\n",
       "      <td>2014-03-24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>510</th>\n",
       "      <td>高校低年级学生频繁试水招聘会 专家：鼓励提前预热</td>\n",
       "      <td>https://www.nfu.edu.cn/gjdt/3f34245a7cb449c99b...</td>\n",
       "      <td>2013-03-31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>511 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                      标题  \\\n",
       "0     如何建设高质量教育体系？“十四五”规划和2035年远景目标纲要明确了   \n",
       "1       教育部长陈宝生《旗帜》撰文：建设高质量教育体系，加快建成教育强国   \n",
       "2            重磅！《推进粤港澳大湾区高等教育合作发展规划》正式印发   \n",
       "3                教育部长陈宝生：大力提升青少年宪法法治教育质量   \n",
       "4             教育系统如何学习贯彻五中全会精神？教育部最新通知来了   \n",
       "..                                   ...   \n",
       "506                 广东省教育厅：今年毕业生就业形势比去年好   \n",
       "507              要求职业“高大上” 高校毕业生择业扎堆致就业难   \n",
       "508  教育部：预计今年贫困地区农村学生上重点高校的人数将比去年增加10%以上   \n",
       "509                       学位论文如何才能挤出“水分”   \n",
       "510             高校低年级学生频繁试水招聘会 专家：鼓励提前预热   \n",
       "\n",
       "                                                    链结          日期  \n",
       "0    https://www.nfu.edu.cn/gjdt/27ba495edc1b49f88b...  2021-03-15  \n",
       "1    https://www.nfu.edu.cn/gjdt/20dc120c250642cca5...  2021-01-05  \n",
       "2    https://www.nfu.edu.cn/gjdt/b43531427fb44695bb...  2020-12-22  \n",
       "3    https://www.nfu.edu.cn/gjdt/1509f4f3bc2f4babbe...  2020-12-15  \n",
       "4    https://www.nfu.edu.cn/gjdt/a4b2fb3dacae456497...  2020-11-20  \n",
       "..                                                 ...         ...  \n",
       "506  https://www.nfu.edu.cn/gjdt/3829e4c5df9e460abc...  2014-03-28  \n",
       "507  https://www.nfu.edu.cn/gjdt/776ebc41fae84b36a4...  2014-03-27  \n",
       "508  https://www.nfu.edu.cn/gjdt/41d339ccb3a0464c9c...  2014-03-25  \n",
       "509  https://www.nfu.edu.cn/gjdt/1e8fa309bcf847b6ad...  2014-03-24  \n",
       "510  https://www.nfu.edu.cn/gjdt/3f34245a7cb449c99b...  2013-03-31  \n",
       "\n",
       "[511 rows x 3 columns]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "session = HTMLSession()\n",
    "r4 = session.get(\"https://www.nfu.edu.cn/gjdt/index.htm\")\n",
    "\n",
    "title = r4.html.xpath('//div[@class=\"news_title\"]/a/@title')\n",
    "links = r4.html.xpath('//div[@class=\"news_title\"]/a/@href')\n",
    "data = r4.html.xpath('//font[@class=\"right-more\"]/text()')\n",
    "\n",
    "for i in range(100):\n",
    "    r4 = session.get(\"https://www.nfu.edu.cn/gjdt/index%d.htm\"%(i))\n",
    "    title.extend(r4.html.xpath('//div[@class=\"news_title\"]/a/@title')) \n",
    "    links.extend(r4.html.xpath('//div[@class=\"news_title\"]/a/@href'))\n",
    "    data.extend(r4.html.xpath('//font[@class=\"right-more\"]/text()'))\n",
    "    \n",
    "df4 = pd.DataFrame( {\n",
    "        \"标题\": title,\n",
    "        \"链结\": [\"https://www.nfu.edu.cn/gjdt/\"+i for i in links],\n",
    "        \"日期\": data,\n",
    "             } )\n",
    "df4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df4.to_excel(\"高校动态.xlsx\", sheet_name=\"南方学院高校动态\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "with pd.ExcelWriter(\"学校官网data.xlsx\") as writer:\n",
    "    df.to_excel(writer,sheet_name=\"学校要闻\"),\n",
    "    df1.to_excel(writer,sheet_name=\"校园动态\"),\n",
    "    df2.to_excel(writer,sheet_name=\"通知公告\"),\n",
    "    df3.to_excel(writer,sheet_name=\"招投标\"),\n",
    "    df4.to_excel(writer,sheet_name=\"高校动态\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
